<?php
/**
 * Created by Dumitru Russu.
 * User: developer
 * Date: 11/23/12
 * Time: 9:18 AM
 * To change this template use File | Settings | File Templates.
 */
class Page_Be_Cron_PublicHoliday extends Page {
	function __construct() {
		parent::__construct();
	}

	public function defaultAction() {
		$year = date('Y');
		$holidayUrl = str_replace('#year#', $year, conf('PUBLIC_HOLIDAY_URL'));
		$row = 1;
		$holidays = Array();
		if (($handle = fopen($holidayUrl, "r")) !== false) {
			while (($data = fgetcsv($handle, 1000, ";")) !== false) {
				if($row != 1) {
					$holidays[] = trim($data[0]);
				}
				$row++;
			}
			fclose($handle);
		}

		$fileData = serialize($holidays);
		$fileName = conf('TEMPORARY_FILE_PUBLIC_HOLIDAYS');
		$file = fopen($fileName, 'w');
		fwrite($file, $fileData);
		fclose($file);
		return array();
	}
}
